<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
    page-type="commonPage"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'base/user/robot/robot',
      // Web路径
      webPath: 'base/user/robot/robot',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "robotTypeCode",
              name: "机器人类型编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "robotTypeName",
              name: "机器人类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "robotCode",
              name: "设备号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "snCode",
              name: "序列号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "pushCode",
              name: "推送识别号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "robotModelCode",
              name: "设备型号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "storeCode",
              name: "门店编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "storeName",
              name: "门店名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "code",
          name: "编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "name",
          name: "名称",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "robotTypeCode",
          name: "机器人类型编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "robotTypeName",
          name: "机器人类型名称",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "robotCode",
          name: "设备号",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "snCode",
          name: "序列号",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "pushCode",
          name: "推送识别号",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "robotModelCode",
          name: "设备型号",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "storeCode",
          name: "门店编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "storeName",
          name: "门店名称",
          type: "text",
          config: {
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                rules: [
                  { required: true, message: '请输入编码', trigger: 'blur' }
                ]
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                rules: [
                  { required: true, message: '请输入名称', trigger: 'blur' }
                ]
              }
            },
            {
              code: "robotTypeCode",
              span: 6,
              name: "机器人类型编码",
              type: "popup",
              config: {
                url: "base/user/robot/robottype",
                filedList: [
                  { code: 'id', name: 'Id' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择机器人类型', trigger: 'blur' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateDTableData(code, row.code)
                  this.$refs.commonPage.updateDTableData("robotTypeName", row.name)
                  this.$refs.commonPage.updateDTableData("robotTypeId", row.id)
                }
              }
            },
            {
              code: "robotTypeName",
              name: "机器人类型名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "robotCode",
              name: "设备号",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "snCode",
              name: "序列号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "pushCode",
              name: "推送识别号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "robotModelCode",
              name: "设备型号",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "storeCode",
              span: 6,
              name: "门店编码",
              type: "popup",
              config: {
                url: "base/user/user/store",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择门店', trigger: 'blur' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateDTableData(code, row.code)
                  this.$refs.commonPage.updateDTableData("storeName", row.name)
                  this.$refs.commonPage.updateDTableData("storeId", row.id)
                }
              }
            },
            {
              code: "storeName",
              name: "门店名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
